﻿using AnesSystem.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AnesSystem.Controls.Operation.SX.PLXYY
{
    /// <summary>
    /// 麻醉单头部基本信息
    /// </summary>
    public partial class AnesRecordBaseInfoCtrl : UserControl
    {
        public AnesRecordBaseInfoCtrl()
        {
            InitializeComponent();
            DataManager.Instance.CurrentPatientLink.AnesthesiaRecord.Brqw = "病房";
            DataManager.Instance.CurrentPatientLink.AnesthesiaRecord.Qtjy = "ST段分析，心率变异分析";
            this.Loaded += AnesRecordBaseInfoCtrl_Loaded;
            zq.CheckChanged += zq_CheckChanged;
            jz.CheckChanged += jz_CheckChanged;
        }
        private void AnesRecordBaseInfoCtrl_Loaded(object sender, RoutedEventArgs e)
        {
            DateTime ssrqda = DataManager.Instance.CurrentPatientLink.Status.InRoomTime;
            string date = Convert.ToDateTime(ssrqda).ToString("yyyy-MM-dd");
            ssrq.Text = date;
            bool fjhuecsstrue = DataManager.Instance.CurrentPatientLink.AnesthesiaRecord.Fjhss;
            if (fjhuecsstrue)
            {
                DataManager.Instance.CurrentPatientLink.QualityPojo.Fjhecss = true;
            }
            InteZqJz();
        }



        private void InteZqJz()
        {
            bool zqtrue = DataManager.Instance.CurrentPatientLink.AnesthesiaRecord.Asa.Zq;
            bool jztrue = DataManager.Instance.CurrentPatientLink.AnesthesiaRecord.Asa.Jz;

            if (zqtrue)
            {
                DataManager.Instance.CurrentPatientLink.AnesthesiaRecord.Js = true;
            }
            else if (jztrue)
            {
                DataManager.Instance.CurrentPatientLink.AnesthesiaRecord.Bjs = true;
            }

        }

        private void zq_CheckChanged(object sender, RoutedEventArgs e)
        {
            CustomCheckBoxCtrl zqCheck = sender as CustomCheckBoxCtrl;

            bool zqtrue = zqCheck.IsChecked;
            if (zqtrue)
            {
                jss.Value = true;
            }
            else
            {
                jss.Value = false;
            }

        }
        private void jz_CheckChanged(object sender, RoutedEventArgs e)
        {
            CustomCheckBoxCtrl jzCheck = sender as CustomCheckBoxCtrl;

            bool zqtrue = jzCheck.IsChecked;
            if (zqtrue)
            {
                jsf.Value = true;
            }
            else
            {
                jsf.Value = false;
            }

        }

        private void BindTextCtrl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            AnesMethodsWin anesMethodsCtrl = new AnesMethodsWin();
            DrugAndEventWindow.Instance.Content = anesMethodsCtrl;
            DrugAndEventWindow.Instance.ShowDialog();
        }
        private void setZhiKonXin()
        {

        }
        private void BindTextCtrl_Loaded(object sender, RoutedEventArgs e)
        {
            if (fjhss.IsChecked)
            {
                DataManager.Instance.CurrentPatientLink.QualityPojo.Fjhecss = true;
            }
        }

        private void fjhss_CheckChanged(object sender, RoutedEventArgs e)
        {
            CustomCheckBoxCtrl check = sender as CustomCheckBoxCtrl;
            bool istrue = check.IsChecked;
            if (istrue)
            {
                DataManager.Instance.CurrentPatientLink.QualityPojo.Fjhecss = true;
            }
        }
    }

}